// 用于生成token 
var jwt = require("jsonwebtoken");
var key = "做大做强，再创辉煌"


module.exports = {
  sign: function (payload, time) { //生成token
    // {phone:188888888,password:9999999}  
    // time token的过期时间   "60s"  "6h"  "6d"
    return jwt.sign(payload, key, { expiresIn: time })
  },
  // tokenId token   callback回调函数
  verify: function (tokenId, callback) {  //验证token
    jwt.verify(tokenId, key, callback)
  }
}
